﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LetiLib.Data;

namespace LedCenter.GUI.PopupControls
{
#if DEBUG
    public partial class TextPopupControl : MiddlePopupControl
#else 
    public partial class TextPopupControl : PopupControl
#endif
    {
        public TextPopupControl():base()
        {
            InitializeComponent();
        }

        public TextPopupControl(TEXT_POPUP p, bool editMode = false)
            : base((POPUP)p, editMode)
        {
            InitializeComponent();

            txtContent.Text = p.Content;
            txtContent.Enabled = isUpdateMode;
        }

        string lastContent = string.Empty;
        protected override void btnUpdate_Click(object sender, EventArgs e)
        {
            lastContent = txtContent.Text;
            base.btnUpdate_Click(sender, e);
            txtContent.Enabled = isUpdateMode;
        }

        protected override void btnCancel_Click(object sender, EventArgs e)
        {
            txtContent.Text = lastContent;   
            base.btnCancel_Click(sender, e);
            txtContent.Enabled = isUpdateMode;
        }

        protected override void btnOK_Click(object sender, EventArgs e)
        {
            ((TEXT_POPUP)_popup).Content = txtContent.Text;
            base.btnOK_Click(sender, e);
            txtContent.Enabled = isUpdateMode;
        }
    }
}
